Socket
Socket
Sign inDemoInstall

@csstools/css-color-parser

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/css-color-parser

Parse CSS color values


Version published
Weekly downloads
1.1M
increased by2.87%
Maintainers
3
Weekly downloads
 
Created

What is @csstools/css-color-parser?

@csstools/css-color-parser is an npm package designed to parse CSS color values. It can handle a variety of color formats including named colors, hex codes, RGB, RGBA, HSL, and HSLA. This package is useful for developers who need to manipulate or validate CSS color values in their JavaScript applications.

What are @csstools/css-color-parser's main functionalities?

Parse Named Colors

This feature allows you to parse named CSS colors. The code sample demonstrates how to parse the named color 'red' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('red');
console.log(color);

Parse Hex Colors

This feature allows you to parse hex color codes. The code sample demonstrates how to parse the hex color '#ff0000' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('#ff0000');
console.log(color);

Parse RGB Colors

This feature allows you to parse RGB color values. The code sample demonstrates how to parse the RGB color 'rgb(255, 0, 0)' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('rgb(255, 0, 0)');
console.log(color);

Parse RGBA Colors

This feature allows you to parse RGBA color values. The code sample demonstrates how to parse the RGBA color 'rgba(255, 0, 0, 0.5)' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('rgba(255, 0, 0, 0.5)');
console.log(color);

Parse HSL Colors

This feature allows you to parse HSL color values. The code sample demonstrates how to parse the HSL color 'hsl(0, 100%, 50%)' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('hsl(0, 100%, 50%)');
console.log(color);

Parse HSLA Colors

This feature allows you to parse HSLA color values. The code sample demonstrates how to parse the HSLA color 'hsla(0, 100%, 50%, 0.5)' and log the resulting color object.

const { parse } = require('@csstools/css-color-parser');
const color = parse('hsla(0, 100%, 50%, 0.5)');
console.log(color);

Other packages similar to @csstools/css-color-parser

Keywords

FAQs

Package last updated on 13 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc